package cn.labbook.bluetooth.mapper;

import cn.labbook.bluetooth.entity.Ammeter;
import cn.labbook.bluetooth.entity.StaticsEntity.ManufactorStatistics;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lonzy
 * @since 2019-03-26
 */
public interface AmmeterMapper extends BaseMapper<Ammeter> {

    ManufactorStatistics getStatisticsByManufactor(@Param("manufacturersId") String manufacturersId);

    ManufactorStatistics getStatisticsByDealer(@Param("dealerId") String dealerId);

    @Select("SELECT admin_id,manager_id FROM ammeter ${ew.customSqlSegment}")
    IPage<Ammeter> groupByPage(IPage<Ammeter> page,@Param("ew") Wrapper<Ammeter> wrapper);

    @Select("select distinct ad.mobilephone from tenant_pay pay \n" +
            "\n" +
            "left join ammeter a on a.ammeter_id = pay.ammeter_id left join admin ad on ad.admin_id = a.manager_id\n" +
            "\n" +
            "where pay.pay_status = 0 and pay.pay_time >= '2022-10-10'")
    List<String> listLandlord();

}
